var CurScreen = 1;
var MaxScreen = 5;
var timer = null;
function $(id) {
    return document.getElementById(id);
}

function switchPic() {
    if (CurScreen == MaxScreen) {
        CurScreen = 1;
    } else {
        CurScreen++;
    }
    $("pic").src = "example" + CurScreen + ".png";
}

function reStart() {
    switchPic();
    init();
}

function pause() {
    clearInterval(timer);
}

function init() {
    timer = setInterval('switchPic();', 1000);
}
